The PAM ("Portable Arbitrary Map"[1]) graphics format of the Netpbm package generalises all the features of the previous formats (PBM, PGM and PPM) and provides for extending them. As well as width, height and maximum value, which are found in the older formats, PAM defines two new attributes: depth and tuple type.
The depth attribute defines the number of channels in the image, such as 1 for greyscale images and 3 for RGB images. The tuple type attribute specifies what kind of image the PAM file represents, thus enabling it to stand for the older Netpbm formats, as well as to be extended to new uses. For example, an image with a tuple type of GRAYSCALE is equivalent to PGM (portable graymap).
Contents |
The header for the PAM file format begins with P7, and (unlike in the other formats) ends in an explicit close: ENDHDR.
There is no plain (human-readable, ASCII-based) version of PAM. PAM files are always binary, and attempts to use the switch -plain
with Netpbm programs that produce PAM output results in an error message.
For the black-and-white version of PAM (depth 1, tuple type BLACKANDWHITE), corresponding to PBM, PAM uses one byte per pixel, instead of PBM’s use of one bit per pixel (packing eight pixels in one byte). Also, the value 1 in such a PAM image stands for white (“light on”), as opposed to black in PBM (“ink on”).
All of the basic tuple types (BLACKANDWHITE, GRAYSCALE, and RGB) have a variant with an opacity channel. The tuple type is created by appending "_ALPHA" as a suffix to the base tuple type. For example tuple type RGB_ALPHA (with depth 4) serves for RGBA images, which previously required the use of a separate PGM image for the opacity channel.
PAM's tuple-type mechanism allows for many extensions. In theory, PAM can be extended to represent colour models like CMYK, and even non-graphical information arrays.